package com.atguigu.gmall.file;

import java.util.concurrent.*;

/**
 * @author ：MJS
 * @date ：Created in 2021/5/14  21:16
 * @description：TODO
 *   异步编排
 *       多线程  核心实现类   多线程复杂交互
 */

public class CompletableFutureDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
       /* new Thread(()->{System.out.println(Thread.currentThread().getName()+"\t"+"insert in");},"A").start();
        System.out.println("哈哈哈");*/
      /* //使用中间人
        FutureTask futureTask =new FutureTask(new MyCallable());
        new Thread(futureTask,"AA").start();
        System.out.println(futureTask.get());
        System.out.println("啧啧");*/
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(
                5,10,1, TimeUnit.SECONDS,new ArrayBlockingQueue<>(10)
        );
        threadPoolExecutor.execute(()->{
            System.out.println(Thread.currentThread().getName()+"\t"+"insert in");
        });
System.out.println(Thread.currentThread().getName()+"\t"+"insert in");
    }
}

class MyCallable implements Callable{
    @Override
    public Object call() throws Exception {
        System.out.println(Thread.currentThread().getName()+"\t"+"insert in");
        return "嘿嘿";
    }
}
